package graphics;

import javax.swing.*;
import java.awt.*;

/**
 * Panel where the main menu is located
 *
 * @author Jared Moore
 * @date 10/5/13
 */
public class MainMenuPanel extends JPanel
{

    private JFrame frame;
	private JLabel label;

	/**
	 * Constructor
	 * Builds the main menu
	 */
    public MainMenuPanel()
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch (ClassNotFoundException | InstantiationException
                | IllegalAccessException | UnsupportedLookAndFeelException e)
        {
            System.err.println("You have an issue with your system");
            e.printStackTrace();
            System.exit(1);
            //if one of these errors are thrown, there is a significant problem with your computer
            //your computer either cannot tell how it formats windows or it cannot use its own theme
            //I like to do this because it gives the panel the look of my system.  Which is much cooler than
            //normal swing stuff
        }
        setLayout(new BorderLayout());
        setFocusable(true);
        label = new JLabel("M.U.L.E", JLabel.CENTER);
        add(label, BorderLayout.NORTH);
	    add(new MainMenuButtonPanel(this), BorderLayout.CENTER);
    }

    /**
     * Sets the frame
     * @param frame The frame to set
     */
    public void setFrame(JFrame frame)
    {
        this.frame = frame;
    }

	/**
	 * Changes the text of the lable at the top
	 * @param text The text to set
	 */
	public void setLabelText(String text)
	{
		label.setText(text);
		repaint();
	}

	/**
	 * Getter for frame
	 * @return The JFrame holding this class
	 */
	public JFrame getFrame() {
		return frame;
	}
}
